package com.hzcx.app.simplechat.ui.home;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.base.BaseDialog;
import com.hzcx.app.simplechat.ui.user.bean.UserInfoBean;
import com.hzcx.app.simplechat.util.empty.EmptyUtils;
import com.hzcx.app.simplechat.util.glide.GlideUtils;
import com.hzcx.app.simplechat.view.imageview.RoundImageView;

import butterknife.BindView;

/**
 * 口令弹窗
 */
public class SloganMenberDialog extends BaseDialog {
    @BindView(R.id.iv_head)
    RoundImageView ivHead;
    @BindView(R.id.tv_nick_name)
    TextView tvNickName;
    @BindView(R.id.tv_sign)
    TextView tvSign;
    @BindView(R.id.view_line)
    View viewLine;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_add_friend)
    TextView tvAddFriend;
    @BindView(R.id.tv_user_id)
    TextView tvUserId;

    private UserInfoBean data;
    private OnSloganAddFriendListener listener;

    public SloganMenberDialog(@NonNull Context context, UserInfoBean data,OnSloganAddFriendListener listener) {
        super(context);
        this.data = data;
        this.listener=listener;
    }

    @Override
    public int getLayout() {
        return R.layout.dialog_slogan_member;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {

        GlideUtils.loadImg(context, data.getAvatar(), ivHead);
        tvNickName.setText(EmptyUtils.isNotEmpty(data.getRemarks_name()) ? data.getRemarks_name() : data.getNickname());
        tvUserId.setText(context.getResources().getString(R.string.app_name) + "号:" + data.getChatnumber());
        tvSign.setText("个性签名:" + data.getBio());

        tvCancel.setOnClickListener(view -> dismiss());

        tvAddFriend.setOnClickListener(view -> {
            if(listener!=null){
                listener.addFriend(data.getMember_id(),EmptyUtils.isNotEmpty(data.getRemarks_name()) ? data.getRemarks_name() : data.getNickname());
            }
            dismiss();
        });
    }

    @Override
    public void initData() {

    }

    public interface OnSloganAddFriendListener {
        void addFriend(int id,String remark);
    }
}
